﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyVoteMVC.Domain;
using System.Data.Entity.ModelConfiguration;

namespace MyVoteMVC.Data.Mapping
{
    public class VT_ProjectsMap : EntityTypeConfiguration<VT_Projects>
    {
        public VT_ProjectsMap()
        {
            // Primary Key
            this.HasKey(t => t.Project_ID);

            this.Property(t => t.Project_Name)
                .HasMaxLength(300);

            this.Property(t => t.Project_Type)
                .HasMaxLength(50);

            this.Property(t => t.Project_Year)
               .HasMaxLength(12);

            this.Property(t => t.Project_Address)
              .HasMaxLength(2000);

            this.Property(t => t.Project_Awards)
            .HasMaxLength(2000);

            this.Property(t => t.Project_Description)
                .HasMaxLength(2000);

            // Table & Column Mappings
            this.ToTable("VT_Projects");
            this.Property(t => t.Project_ID).HasColumnName("Project_ID");
            this.Property(t => t.Project_Name).HasColumnName("Project_Name");
            this.Property(t => t.Project_Type).HasColumnName("Project_Type");
            this.Property(t => t.Project_Year).HasColumnName("Project_Year");
            this.Property(t => t.Project_Address).HasColumnName("Project_Address");
            this.Property(t => t.Project_Awards).HasColumnName("Project_Awards");
            this.Property(t => t.Project_Description).HasColumnName("Project_Description");
            

            this.HasRequired(t => t.ProjectImage)
            .WithRequiredPrincipal();

        }
    }

    public class VT_ProjectImageMap : EntityTypeConfiguration<VT_ProjectImage>
    {
        public VT_ProjectImageMap()
        {

            this.HasKey(t => t.Project_ID);

            this.ToTable("VT_Projects");
            this.Property(t => t.Project_Image).HasColumnName("Project_Image");
            this.Property(t => t.Project_Thumbnail).HasColumnName("Project_Thumbnail");

        }
    }
}
